package com.hopes.bizz.risk.setting.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.hopes.bizz.risk.setting.entity.RiskConfigLEntity;
import com.hopes.bizz.risk.setting.entity.RiskConfigLecEntity;
import com.hopes.boss.admin.api.entity.SysDictItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description LEC 辨识对象
 * @time 2023/7/21 13:08
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class RiskLecIdentifyVO implements Serializable {

    private static final long serialVersionUID = -2181079082067118706L;

    /**
     * 风险等级
     */
    private List<SysDictItem> riskLevelList;

    /**
     * LEC  L-事故发生可能性等设置
     */
    private List<RiskConfigLVO> riskLecLList;

    /**
     * LEC E-
     */
    private List<RiskConfigLVO> riskLecEList;

    /**
     * LEC C-
     */
    private List<RiskConfigLVO> riskLecCList;

    /**
     * LEC
     */
    private List<RiskConfigLecEntity> riskLecConfigList;


    public static List<RiskConfigLVO> entity2VO(List<RiskConfigLEntity> collection) {
        if (CollectionUtil.isEmpty(collection)) {
            return new ArrayList<>();
        }
        return collection.stream().map(item -> {
            final RiskConfigLVO riskConfigLVO = new RiskConfigLVO();
            BeanUtils.copyProperties(item, riskConfigLVO);
            riskConfigLVO.setRemarks("(" + item.getRiskValue() + ")" + item.getRemarks());
            return riskConfigLVO;
        }).collect(Collectors.toList());
    }


}
